package com.sky.common.framework.dto.resp;

import com.sky.common.util.StatusCode;
import com.sky.common.util.StatusCodeConst;
import com.sky.common.util.StatusCodeManager;

public class ResponseBean<T> {

	private boolean success;

	private String code;

	private String message;

	private String requestId;

	private T data;

	public ResponseBean() {
	}

	public ResponseBean(boolean success) {
		this.success = success;
		if (this.success) {
			this.code = "200";
			this.message = StatusCodeManager.getCodeMsg(code);
		}
	}

	public ResponseBean(String code) {

		this.success = StatusCodeConst.SUCCESS.equals(code);
		this.code = code;
		this.message = StatusCodeManager.getCodeMsg(code);
	}

	public ResponseBean(String code, String msg) {

		this.success = StatusCodeConst.SUCCESS.equals(code);
		this.code = code;
		this.message = msg;
	}
	
	public ResponseBean(T data){
		
		this(true);
		this.data = data;
	}
	
	public ResponseBean(StatusCode code){
		this(code.getCode(),code.getMsg());
	}

	@Override
	public String toString() {
		return "ResponseBean [success=" + success + ", code=" + code + ", message=" + message + ", requestId="
				+ requestId + ", data=" + data + "]";
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getRequestId() {
		return requestId;
	}

	public void setRequestId(String requestId) {
		this.requestId = requestId;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
